using System.Collections.Generic;

namespace SharpErp.Data.Util
{
    public class SharpCalc
    {
        class Token{
           /// <summary>
           /// "("
           /// </summary>
           public const int TK_OPERATOR_LEFT        = 1; 
           /// <summary>
           /// ")"
           /// </summary>
           public const int TK_OPERATOR_RIGHT       = 2;
           /// <summary>
           /// "+"
           /// </summary>
           public const int TK_OPERATOR_ADD         = 3;
           /// <summary>
           /// "-"
           /// </summary>
           public const int TK_OPERATOR_SUB         = 4;
           /// <summary>
           /// "*"
           /// </summary>
           public const int TK_OPERATOR_MUL         = 5;
           /// <summary>
           /// "/"
           /// </summary>
           public const int TK_OPERATOR_DIV         = 6;
           /// <summary>
           /// "function"
           /// </summary>
           public const int TK_OPERATOR_FUNCTION    = 7;
           /// <summary>
           /// 12.3456
           /// </summary>
           public const int TK_OPERATOR_NUMBER      = 8;
           /// <summary>
           /// property
           /// </summary>
           public const int TK_OPERATOR_VARIABLE    = 9;
           
           public string strValue;
           
           public double GetDoubleValue(){
               return double.Parse(strValue);
           }
           
           public string GetValue(){
               return strValue;
           }
           
        }
        
        public double Calc(object obj, string expression){
            double result = 0;
            return result;
        }
        
        public double Calc(Dictionary<string, double> variables, string expression){
            double result = 0;
            var operatorStack = new Stack<Token>();
            var operandStack = new Stack<Token>();
            return result;
        }
        
        private void Parse(Stack<Token> operandStack, Stack<Token> operatorStack, string expression){
            var pos = expression.IndexOf('=');
            if(pos < 0){
            }
            expression = expression.Trim();
            expression = 
        }
    }
}
